<template>
  <div class="news">
    <div class="newsHeader">
      <a href="#" @click="news">
        <img src="../../static/img/fanhui@2x.png" alt="">
      </a>
      <span>独家定制</span>
    </div>
    <div class="newsMain" v-for="(news,index) in list">
      <h3 class="newsTitle">{{news.title}}</h3>
      <span class="newsTime">{{news.time}}</span>
      <div style="margin-top: 0.6rem;">
        <div class="newsBox" v-for="box in news.boxs">
          <p>{{box.p}}</p>
          <img :src="box.img">
        </div>
      </div>

    </div>
    <div class="newsFooter"></div>
  </div>
</template>
<script>
  import {Lazyload} from 'mint-ui';
  import Vue from 'vue'
  //  实现背景图片懒加载（利用mint-ui）
  Vue.use(Lazyload, {
    preLoad: 1.3,
    error: 'http://img.mp.sohu.com/upload/20170519/6e8fd80f38774e9c9be2b1a9b84e3e79.gif',
    loading: 'http://img.zcool.cn/community/014b0058d4daa8a801219c77fb0158.gif',
    attempt: 1
  });
  export default {
    name: "news",
    data() {
      return {
        list: []
      }
    },
    mounted: function () {
      this.getData()
    },
    methods: {
      getData() {
        var id = this.$route.query.id;
        var _this = this;
        this.$http.get("/static/information.json").then(res => {
          for (var i = 0; i < res.body.list.length; i++) {
            if (res.body.list[i].id == id) {
              _this.list.push(res.body.list[i])
            }
          }
        })
      },
      news() {
        this.$router.go(-1)
      }
    },
  }
</script>


<style>
  .news {
    position: relative;
    width: 100%;
    background: #fff;
  }

  .newsHeader {
    width: 100%;
    z-index: 1;
    height: 1.3rem;
    line-height: 1.3rem;
    font-size: 15px;
    background: #3aab35;
    position: fixed;
    top: 0;
    left: 0;
    -webkit-box-shadow: 0 0 10px #cecece;
    box-shadow: 0 0 10px #cecece;
    text-align: center;
    color: #fff;
  }

  .newsHeader img {
    display: block;
    float: left;
    width: 9px;
    height: 16px;
    padding: 16px;
    color: black;
  }

  .newsMain {
    margin-top: 40px;
    background: white;
  }

  .newsTitle {
    padding-top: 20px;
    width: 282px;
    margin: auto;
    text-align: center;
    font-size: 25px;
    font-family: "华文行楷";
    font-weight: normal;
  }

  .newsTime {
    text-align: center;
    display: block;
    margin-top: 0.1rem;
    padding: 9px;
  }

  .newsBox p {
    padding-left: 13px;
    font-size: 15px;
    line-height: 25px;
    font-family: 微软雅黑, sans-serif;
  }

  .newsBox img {
    width: 9.3rem;
    display: block;
    margin: auto;
    margin-bottom: 2px;
  }

</style>
